import { Component, Input, OnInit } from '@angular/core';
import { ActivatedRoute } from '@angular/router';
import { MemberVo } from 'src/app/model/member-vo';
import { map } from 'rxjs/operators';
import { ReportEntityDataService } from 'src/app/services/report-entity-data.service';
@Component({
  selector: 'app-member-item-embed',
  templateUrl: './member-item-embed.component.html',
  styles: [``]
})
export class MemberItemEmbedComponent implements OnInit {
  //话题内容页的会员信息
  @Input('member')
  public member!: MemberVo;
  @Input('publishDate')
  public replyDate!: Date;
  @Input('replyFloor')
  public replyFloor!: number;
  @Input('replyId')
  public replyId!: number;
  @Input('author')
  public threadsAuthor!: number;
  //当前话题的连接
  public threadsLink: string = '#';

  constructor(
    private activatedRoute: ActivatedRoute, 
    private reportShare: ReportEntityDataService) {
    this.activatedRoute.url.pipe(map(s => s.join('/'))).subscribe(res => {
      this.threadsLink = '/' + res;
    });
  }

  ngOnInit(): void {
    //console.dir(this.member);
  }

  //举报的回复ID发送至<Subject>
  public toggleReport(replyId: number, replyFloor: number): void {
    this.reportShare.send(replyId, replyFloor);
  }
}